Skip to content

Remove Fortran parser special-case for C declarations and generalize invalid-syntax handling - #36

Merged
saidctb merged 2 commits into
errorsfrom
codex/fix-error-detection-in-foreign-language-parsing
May 27, 2026
Merged

Remove Fortran parser special-case for C declarations and generalize invalid-syntax handling#36
saidctb merged 2 commits into
errorsfrom
codex/fix-error-detection-in-foreign-language-parsing

Conversation

@saidctb

@saidctb saidctb commented May 27, 2026

Copy link
Copy Markdown
Contributor

Motivation

  • Remove fragile, C-specific regex checks that attempted to recognize foreign C declarations in Fortran sources and instead treat unknown top-level lines as generic invalid Fortran syntax.
  • Make the parser's top-level validation language-agnostic so non-Fortran constructs are rejected by the generic invalid-syntax path rather than by a dedicated C-declaration detector.
  • Simplify the parser code by removing duplicate checks scattered in several spec/contains parsing helpers.

Description

  • Deleted the _FOREIGN_C_DECLARATION and _FOREIGN_C_ALIAS_DECLARATION regexes and the _raise_if_foreign_c_syntax_line helper, removing the C-specific detection logic.
  • Updated _helper_validate_file_scope_unparsed_lines to use a generic invalid-syntax diagnostic and added a clarifying docstring about the language-agnostic guard.
  • Removed calls to the removed _raise_if_foreign_c_syntax_line check from specification visitors and derived-type parsing helpers so non-Fortran lines are handled by _raise_invalid_fortran_syntax_line instead.
  • Adjusted tests to reflect the new generic error reporting: updated expectations in tests/parser/test_error_handling.py, tests/parser/test_cli.py, and tests/parser/c/test_c_functions.py to accept the generic invalid-syntax codes/messages.

Testing

  • Ran the parser-focused test subset with pytest tests/parser which includes the modified tests, and all tests in that subset passed.
  • Executed the updated tests tests/parser/test_error_handling.py, tests/parser/test_cli.py, and tests/parser/c/test_c_functions.py and they succeeded with the new generic error behavior.
  • No remaining tests relied on the removed C-specific diagnostics after updating their assertions, and the parser tests completed successfully.

Codex Task

@codecov

codecov Bot commented May 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
py312 94.56% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@saidctb
saidctb merged commit 53af1ab into errors May 27, 2026
4 of 5 checks passed
@saidctb
saidctb deleted the codex/fix-error-detection-in-foreign-language-parsing branch May 27, 2026 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant